module_model_list = MetaModel.module_to_models.setdefauts(cls._module,[])
if cls not in module_model_list:
    if not cls._custom:
        module_model_list.append(cls)
        

class rhwl_order(osv.osv):
    _inherit = "procurement.order"
    
    def run_scheduler(self,cr ,uid, user_new_cursor=False, company_id=False,context=None):
        super(rhwl_order,self).run_scheduler(cr,uid,use_new_cursor, company_id, context)
        move_obj = self.pool.get("stock.move")
        move_ids = move_obj.search(cr, uid,[('state','not in',['done','cancel']),('express_no','=',False)], context=context)
        

class rhwl_order(osv.osv):
    _inherit = "procurement.order"
    
    def run_scheduler(self,cr ,uid, user_new_cursor=False, company_id=False,context=None):
        super(rhwl_order,self).run_scheduler(cr,uid,use_new_cursor, company_id, context)
        try:
            if use_new_cursor:
                cr = openerp.registry(cr.dbname).cursor()
            move_obj = self.pool.get('stock.move')
            move_ids = move_obj.search(cr,uid,[('state','not in',['done','cancel']),(express_no','=',False)],context = context)
            if use_new_cursor:
                cr.commit()
        finally:
            if use_new_cursor:
                try:
                    cr.close()
                except:
                    pass
        return {}
        
        
        
#        move_obj = self.pool.get("stock.move")
#        move_ids = move_obj.search(cr, uid,[('state','not in',['done','cancel']),('express_no','=',False)], context=context)
        
class extend_user(osv.osv):
    _name = 'res.users'
    _inherit = ['res.users']
    
    #返回我的id
    def _write_mine_id(self,cr,uid,ids,name,args,context=None):
        result = dict.fromkeys(ids,1024)
        return result
    
    _columns = {
        'context_mine_id': fields.function(_write_mine_id, type='integer'),
    }
    
extend_user()

        
class extend_user(osv.osv):
    _name = 'res.users'
    _inherit = ['res.users']
    
    #获取用户关联的部门
    def _get_self_department_ids(self, cr ,uid, ids, name, args, context=None):
        result = dict.fromkeys(ids, False)
        emp = self.pool.get('hr.empolyee')
        for id in ids:
            emp_ids = emp.search(cr,uid,[('user_id','=',id)],context = context)
            emp = emp.browse(cr,uid,emp_ids[0],context=context)
            result[id] = emp.department_id
        return result
        
    _columns = {
        'context_department_id': field.function(_get_self_department_ids,type = "hr.departemt"),
    }
    
extend_user()



















        
        
        
        
        
        
        
        